﻿using System;
using Internal.KuiHuaBaoDian.Services.Avatar;
using KuiHuaBaoDian.Services.Asset;
using UnityEngine;

namespace KuiHuaBaoDian.Services.Avatar {

    public readonly struct AvatarHandle : IAssetInstantiateParent {

        /// <summary>
        /// 空值
        /// </summary>
        public static readonly AvatarHandle None = new();

        /// <summary>
        /// GUID
        /// </summary>
        public Guid GUID { get; init; }

        Transform IAssetInstantiateParent.Transform => (AvatarService.Instance as IAvatarServiceInternal).GetTransform(this);

        public override readonly string ToString() => $"[{nameof(AvatarHandle)}({GUID})]";

        public override readonly int GetHashCode() => GUID.GetHashCode();

        public override readonly bool Equals(object obj) {
            if (obj is AvatarHandle other) {
                return other.GUID == GUID;
            }
            return false;
        }
    }
}
